﻿using System;
using System.Linq.Expressions;
using Domain.Core.Specification;
using Domain.MainModule.Entities;

namespace Domain.MainModule.Addresses
{
    public class AddressTypeNameSpecification : Specification<AddressType>
    {
        #region public properties

        public string AddressTypeName
        {
            get;
            set;
        }

        #endregion

        #region constructor

        public AddressTypeNameSpecification(string addressTypeName)
        {
            this.AddressTypeName = addressTypeName;
        }

        #endregion

        #region public methods

        public override Expression<Func<AddressType, bool>> SatisfiedBy()
        {
            Specification<AddressType> spec = new TrueSpecification<AddressType>();
            spec &= new DirectSpecification<AddressType>(c => c.Name.ToLower() == this.AddressTypeName.ToLower());

            return spec.SatisfiedBy();
        }

        #endregion
    }
}
